package com.hyt.it.ogt.kq.common.gov.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 身份类型
 *
 * @author yaojian
 * @createTime 2021/12/03
 */
@Getter
public enum IdentityTypeEnum {

    MAINLAND_RESIDENT_IDENTITY_CARD(0, "大陆居民身份证"),
    HONG_KONG_MACAO_TAIWAN_ID_CARD(1, "港澳台身份证"),
    PASSPORT(2, "护照"),
    ;

    private String name;
    private Integer type;
    private String desc;

    IdentityTypeEnum(Integer type, String desc) {
        this.name = name();
        this.type = type;
        this.desc = desc;
    }

    public static String[] allDesc() {
        return Arrays.stream(values())
                .map(IdentityTypeEnum::getDesc)
                .toArray(String[]::new);
    }

    public static String getTypeByDesc(String desc) {
        for (IdentityTypeEnum identityTypeEnum : values()) {
            if (identityTypeEnum.getDesc().equals(desc)) {
                return identityTypeEnum.getType().toString();
            }
        }
        return null;
    }

    public static String getDescByType(Integer type) {
        for (IdentityTypeEnum identityTypeEnum : values()) {
            if (identityTypeEnum.getType().equals(type)) {
                return identityTypeEnum.getDesc();
            }
        }
        return null;
    }
}
